﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WucCloud.Entity;

namespace WucCloud.WebApi
{
    /// <summary>
    /// AutoMapper
    /// </summary>
    public class AutoMapperProfile : Profile
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public AutoMapperProfile()
        {
            //1.两个实体字段一致时，可直接创建映射            
            CreateMap<UserInfoEntity, UserInfoDto>();
            CreateMap<UserInfoDto, UserInfoEntity>();

            CreateMap<RoleInfoEntity, RoleInfoDto>();
            CreateMap<RoleInfoDto, RoleInfoEntity>();

            CreateMap<MenuInfoEntity, MenuInfoDto>();
            CreateMap<MenuInfoDto,MenuInfoEntity>();

            //2.若两个实体字段不一致时,需要为属性成员指定对应的映射关系
            //CreateMap<UserInfoEntity, UserInfoDto>().ForMember(des => des.CreateTime, mem => mem.MapFrom(c => c.CreateDate));
        }
    }
}
